type t1 = gen any

fn std_args():[string]

fn htons(u16 host):u16

/* ISO C `broken-down time' structure.  */
type libc_tm_t = struct {
    i32 tm_sec
    i32 tm_min
    i32 tm_hour
    i32 tm_mday
    i32 tm_mon
    i32 tm_year
    i32 tm_wday
    i32 tm_yday
    i32 tm_isdst
    i64 tm_gmtoff
    cptr tm_zone
}

// 标准库函数, 返回值是静态值，不用处理 gc 但是线程不安全
fn localtime(ptr<i64> timestamp):ptr<libc_tm_t>

// 将 time_info_t 转换为时间戳
fn mktime(ptr<libc_tm_t> time_info):i64

// strftime(buf.ref(), buf.len, '%Y-%m-%d %H:%M:%S', &tp)
fn strftime(cptr s, i64 size, cptr format, ptr<libc_tm_t> time_info):i64

// 通过空值 options 实现阻塞和非阻塞模式
fn waitpid(int pid, ptr<int> status, int options):int

// --- signal 相关 <sys/signalfd.h> 和 <signal.h>
type sigset_t = struct {
    arr<u64,16> __val
}

type signalfd_siginfo_t = struct {
    u32 ssi_signo
    i32 ssi_errno
    i32 ssi_code
    u32 ssi_pid
    u32 ssi_uid
    i32 ssi_fd
    u32 ssi_tid
    u32 ssi_band
    u32 ssi_overrun
    u32 ssi_trapno
    i32 ssi_status
    i32 ssi_int
    u64 ssi_ptr
    u64 ssi_utime
    u64 ssi_stime
    u64 ssi_addr
    u16 ssi_addr_lsb
    u32 __pad2
    i32 ssi_syscall
    u64 ssi_call_addr
    u32 ssi_arch
    arr<u8,48> __pad
}

fn sigemptyset(ptr<sigset_t> sigset):i32

fn sigaddset(ptr<sigset_t> sigset, i32 signo):i32

fn sigfillset(ptr<sigset_t> sigset):i32

fn sigprocmask(i32 how, ptr<sigset_t> sigset, cptr<sigset_t> oldset):i32

fn signalfd(int fd, ptr<sigset_t> mask, i32 flags):i32

fn sleep(int second)

fn usleep(u32 usec):i32

fn strtol(cptr str, cptr endptr, i32 base):i64

fn prctl(int option, u64 arg2, u64 arg3, u64 arg4, u64 arg5):int

fn srand(u32 seed)

fn rand():int

fn clock():int

// --- 自定义在 runtime/libc 模块中的函数
// cptr = char*
fn libc_string_new(cptr s):string

fn libc_string_replace(string str, string old, string new_str):string

// 读取 errno 中的错误信息
fn libc_strerror():string

// 读取当前全局的 errno 编码
fn libc_errno():int

fn libc_get_envs():[string]
